﻿<ribbon:RibbonWindow x:Class="LocationWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
		Title="LocationWindow"
					 xmlns:local="clr-namespace:ATS.UI.WPF"
		x:Name="LocationWindow"
		Width="640" Height="580" Icon="../../images/Main/keys.png">
    <ribbon:RibbonWindow.Resources>
        <local:HalfValueConverter x:Key="HalfValue" />
        <Style TargetType="Label" x:Key="MyLabel">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontSize" Value="50"/>
            <Setter Property="Background" Value="LightBlue" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Label}">
                        <Border BorderThickness="{TemplateBinding BorderThickness}"
								BorderBrush="{TemplateBinding BorderBrush}"
								Padding="{TemplateBinding Padding}"
								SnapsToDevicePixels="true">
                            <Grid>
                                <Rectangle Fill="{TemplateBinding Background}">
                                    <Rectangle.OpacityMask>
                                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                            <GradientStop Color="#80000000" Offset="0.0" />
                                            <GradientStop Color="#E6000000" Offset="0.5" />
                                            <GradientStop Color="#80000000" Offset="1.0" />
                                        </LinearGradientBrush>
                                    </Rectangle.OpacityMask>
                                </Rectangle>
                                <ContentPresenter
									HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
									VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
									RecognizesAccessKey="True"
									SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground"
										Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="{x:Type ListBoxItem}" TargetType="{x:Type ListBoxItem}">
            <Setter Property="OverridesDefaultStyle" Value="true" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Padding" Value="3" />
            <Setter Property="Opacity" Value=".80" />
            <Setter Property="LayoutTransform">
                <Setter.Value>
                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border Background="{TemplateBinding Background}" 
								BorderBrush="{TemplateBinding BorderBrush}" 
								BorderThickness="{TemplateBinding BorderThickness}" 
								Padding="{TemplateBinding Padding}">
                            <ContentPresenter x:Name="ContentSite" 
											  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
											  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                            <LinearGradientBrush.GradientStops>
                                                <GradientStop Offset="0" Color="LightGray"/>
                                                <GradientStop Offset="1" Color="DarkGray"/>
                                            </LinearGradientBrush.GradientStops>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="BorderBrush" Value="Silver" />
                                <Setter Property="Opacity" Value="1"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true" />
                                    <Condition Property="Selector.IsSelectionActive" 
											   Value="false" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" Value="LightGray" />
                                <Setter Property="BorderBrush" Value="DarkGray" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="Gray" />
                </Trigger>
                <EventTrigger RoutedEvent="Mouse.MouseEnter">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <!--DoubleAnimation Duration="0:0:0.0"                                                 
												 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleY)"
												 From="1" To="1.125"/>
									<DoubleAnimation Duration="0:0:0.0"                                                 
												 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleX)"
												 From="1" To="1.125"/-->
                                <DoubleAnimation Duration="0:0:0.2"
												 Storyboard.TargetProperty="Opacity"
												 To="1.0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
                <EventTrigger RoutedEvent="Mouse.MouseLeave">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <!--DoubleAnimation Duration="0:0:0.0"
												 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleY)"
												 From="1.125" To="1"/>
									<DoubleAnimation Duration="0:0:0.0"                                                 
												 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleX)"
												 From="1.125" To="1"/-->
                                <DoubleAnimation Duration="0:0:0.2"
												 Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Style.Triggers>
        </Style>
        <DataTemplate x:Key="listBoxTemplate">
            <Border BorderBrush="Blue"
					BorderThickness="1"
					CornerRadius="1"
					Margin="1">
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="{Binding LocationName}" 
							   Foreground="Green" 
							   FontWeight="Bold"
								   Name="username" Margin="1"/>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0">
                        <Label Content ="Code : " 
							   Foreground="Black" HorizontalAlignment="Left"  VerticalAlignment="Center" />
                        <Label Content="{Binding LocationCode}" 
							   Foreground="Green" Name="categoryCode" HorizontalAlignment="Left"  VerticalAlignment="Center"/>
                    </StackPanel>
                </StackPanel>
            </Border>
        </DataTemplate>
    </ribbon:RibbonWindow.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ribbon:Ribbon x:Name="Ribbon" Grid.Row="0">
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu Visibility="Collapsed" >
                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>
            <ribbon:Ribbon.QuickAccessToolBar>
                <ribbon:RibbonQuickAccessToolBar Visibility="Collapsed"></ribbon:RibbonQuickAccessToolBar>
            </ribbon:Ribbon.QuickAccessToolBar>

            <ribbon:RibbonTab x:Name="LocationTab"
							  
							  Header="Location">
                <ribbon:RibbonGroup x:Name="Actions"
									Header="Actions">
                    <ribbon:RibbonButton x:Name="buttonNew"
										 LargeImageSource="../../images/actions/ctrladd.png"
										 Label="New" />
                    <ribbon:RibbonButton x:Name="buttonRefresh"
										 LargeImageSource="../../images/actions/Refresh-64.png"
										 Label="Refresh" />
                    <ribbon:RibbonButton x:Name="buttonSave"
										 LargeImageSource="../../images/actions/ctrlsave.png"
										 Label="Save" />
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="SearchTab"							  
							  Header="Search">
            </ribbon:RibbonTab>

        </ribbon:Ribbon>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Expander Width="Auto" ExpandDirection="Right" HorizontalAlignment="Right" Grid.Column="0" x:Name="ExpanderList">
                <Expander.Header>
                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" Width="Auto" Name="ExpanderText">
						<TextBlock.LayoutTransform>
							<TransformGroup>
								<ScaleTransform ScaleX="1" ScaleY="1"/>
								<SkewTransform AngleX="0" AngleY="0"/>
								<RotateTransform Angle="90"/>
								<TranslateTransform X="0" Y="0"/>
							</TransformGroup>
						</TextBlock.LayoutTransform>
						<TextBlock.RenderTransform>
							<TransformGroup>
								<ScaleTransform ScaleX="1" ScaleY="1"/>
								<SkewTransform AngleX="0" AngleY="0"/>
								<RotateTransform Angle="0"/>
								<TranslateTransform X="0" Y="0"/>
							</TransformGroup>
						</TextBlock.RenderTransform>
                    </TextBlock>
                </Expander.Header>
                <Border Name="borderHeader" BorderBrush="Gray" BorderThickness="1,1,1,1" CornerRadius="6,6,6,6">
                    <Grid Name="gridListbox"  VerticalAlignment="Stretch" Height="auto">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal" 
									Background="Aquamarine"
									VerticalAlignment="Top"
									Margin="2" Grid.Row="0">
                            <TextBox MinHeight="10" 
									 MinWidth="126"
									 Margin="2"
									 Name="searchBox">Search</TextBox>
                        </StackPanel>
                        <ListBox Name="listBoxLocations"
								 Grid.Row="1"
								 HorizontalContentAlignment="Stretch"
								 ItemContainerStyle="{DynamicResource ListBoxItem}"
								 ItemTemplate="{StaticResource listBoxTemplate}"
								 IsSynchronizedWithCurrentItem="True"
								 ItemsSource="{Binding}"
								 VerticalAlignment="Top"  
								 Height="auto"></ListBox>
                        <Control Grid.RowSpan="2"
								 x:Name="busyAnimation" 
								 Style="{StaticResource BusyAnimationStyle}"
								 Width="{Binding Path=ActualWidth, ElementName=listBoxLocations}" 
								 Height="{Binding Path=ActualHeight, ElementName=imagelistBoxUsers}" />

                    </Grid>
                </Border>
            </Expander>
            <Border Name="borderHeader1" 
				Grid.Column="1" 
				BorderBrush="Gray" 
				BorderThickness="1,1,1,1" 
				CornerRadius="6,6,6,6">
                <Grid>
                    <ScrollViewer>
                        <StackPanel VerticalAlignment="Top">
                            <Grid Name="gridLocationDetails">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto"></RowDefinition>
                                    <RowDefinition Height="auto"></RowDefinition>
                                    <RowDefinition Height="auto"></RowDefinition>
                                    <RowDefinition Height="auto"></RowDefinition>
                                    <RowDefinition Height="auto"></RowDefinition>
                                    <RowDefinition Height="auto"></RowDefinition>
                                    <RowDefinition Height="auto"></RowDefinition>
                                    <RowDefinition Height="auto"></RowDefinition>
                                    <RowDefinition Height="auto"></RowDefinition>
                                </Grid.RowDefinitions>
                                <Label Margin="5" HorizontalAlignment="Left" FontWeight="bold" Grid.Row="0">Location</Label>
                                <Label Margin="5,5,5,0" HorizontalAlignment="Left" Grid.Row="1">Code</Label>
                                <TextBox Margin="5,0,5,5" HorizontalAlignment="Left" Grid.Row="2" Width="150" Name="textboxCode"
										 Text="{Binding Path=LocationCode
									, UpdateSourceTrigger=PropertyChanged
									, ValidatesOnExceptions=True
									, TargetNullValue=''
									, NotifyOnValidationError=True}"
										 Validation.Error="TextBox_Error"
										 IsReadOnly="True"></TextBox>
                                <Label Margin="5,5,5,0" HorizontalAlignment="Left" Grid.Row="3">Name</Label>
                                <TextBox Margin="5,0,5,5" HorizontalAlignment="Left" Grid.Row="4" Width="300" Name="textboxName"
										 Text="{Binding Path=LocationName
									, UpdateSourceTrigger=PropertyChanged
									, ValidatesOnExceptions=True
									, TargetNullValue=''
									, NotifyOnValidationError=true, Mode=TwoWay}"
										 Validation.Error="TextBox_Error"></TextBox>
                                <Label Margin="5,5,5,0" HorizontalAlignment="Left" Grid.Row="5">Description</Label>
                                <TextBox Margin="5,0,5,5" HorizontalAlignment="Left" Grid.Row="6" Width="300" Height="100" Name="textboxDescription"
                                         Text="{Binding Path=LocationDesc
									, UpdateSourceTrigger=PropertyChanged}"></TextBox>
                                <StackPanel Grid.Row="7" Orientation="Horizontal">
                                    <CheckBox Margin="5" 
										  Name="CheckBoxIsActive"										  
										  IsChecked="{Binding Path=IsActive}" VerticalAlignment="Center"/>
                                    <Label Margin="5" HorizontalAlignment="Left" >Is Active</Label>
                                </StackPanel>
                                

                            </Grid>
                        </StackPanel>
                    </ScrollViewer>
                </Grid>
            </Border>
            <Border Name="mainOverlay" Grid.Column="1" CornerRadius="6,6,6,6">
                <DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="LightBlue">
                    <DockPanel.OpacityMask >
                        <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,1">
                            <GradientStop Color="#80000000" Offset="0.0" />
                            <GradientStop Color="#E6000000" Offset="0.5" />
                            <GradientStop Color="#80000000" Offset="1.0" />
                        </LinearGradientBrush>
                    </DockPanel.OpacityMask >

                    <Label  VerticalAlignment="Center" HorizontalAlignment="Center" Style="{StaticResource MyLabel}">empty record</Label>

                </DockPanel>
            </Border>
        </Grid>
        <Canvas Name="NewItemCanvas" Grid.Column="1"  Visibility="Collapsed" Grid.RowSpan="2" Grid.Row="0" >
            <Canvas.Background>
                <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,1">
                    <GradientStop Color="#80000000" Offset="0.0" />
                    <GradientStop Color="#E6000000" Offset="0.5" />
                    <GradientStop Color="#80000000" Offset="1.0" />
                </LinearGradientBrush>
            </Canvas.Background>
            <local:ucNewItem  x:Name="ucNewItem"  Width="250"
					 Height="125">
                <Canvas.Left>
                    <MultiBinding Converter="{StaticResource HalfValue}">
                        <Binding ElementName="NewItemCanvas" Path="ActualWidth" />
                        <Binding ElementName="ucNewItem" Path="ActualWidth" />
                    </MultiBinding>
                </Canvas.Left>
                <Canvas.Top>
                    <MultiBinding Converter="{StaticResource HalfValue}">
                        <Binding ElementName="NewItemCanvas" Path="ActualHeight" />
                        <Binding ElementName="ucNewItem" Path="ActualHeight" />
                    </MultiBinding>
                </Canvas.Top>

            </local:ucNewItem>
        </Canvas>
        <Control Grid.RowSpan="2"
								 x:Name="busyAnimationSaveAndDelete" 
								 Style="{StaticResource BusyAnimationStyle}"
								 Width="{Binding Path=ActualWidth, ElementName=mainGrid}" 
								 Height="{Binding Path=ActualHeight, ElementName=mainGrid}" 
				 Visibility="Collapsed" />
    </Grid>
</ribbon:RibbonWindow>
